package com.example.userservice.common;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {
    private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
    //全局捕获运行时异常
    @ExceptionHandler(RuntimeException.class)
    public Result<?> handleException(RuntimeException e) {
        log.warn(e.getMessage(), e);
        return Result.failure(e.getMessage());
    }
}
